package com.bw.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;


public class HightExcelTest {
	public static void main(String[] args) {
		String[] title = {"编号", "学生姓名", "所在班级", "就业状态", "联系状态", "当日时间", "公司", "面试状态", "录音资料", "毕业前指导", "毕业后指导", "录音诊断", "今日是否联系", "面试时间"};
		//创建excel工作薄
		@SuppressWarnings("resource")
		HSSFWorkbook workbook = new HSSFWorkbook();
		//创建一个工作表sheet
		Sheet createSheet = workbook.createSheet();
		//创建第一行
		Row row = createSheet.createRow(0);
		Cell cell = null;
		//插入第一行数据，id，name, sex
		for(int i = 0; i < title.length; i++){
			cell = row.createCell(i);
			cell.setCellValue(title[i]);
		}
		for(int i = 1; i <= 10; i++){
			Row nextrow = createSheet.createRow(i);
			Cell cell2 = nextrow.createCell(0);
			cell2.setCellValue("a"+ i);
			cell2 = nextrow.createCell(1);
			cell2.setCellValue("user"+ i);
			cell2 = nextrow.createCell(2);
			cell2.setCellValue("男");
		}
		File file = new File("d://poi.xlsx");
		try {
			file.createNewFile();
			FileOutputStream stream = FileUtils.openOutputStream(file);
			workbook.write(stream);
			stream.close();
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}